﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using ExtBusiness.Dictionary;

public partial class WebPubManager_DictionaryAdd : System.Web.UI.Page
{
    private DictOperation dicOperation = new DictOperation();

    protected void Page_Load(object sender, EventArgs e)
    {
        string action = Request.QueryString["action"];

        if (!IsPostBack)
        {
            DataTable dtSource = dicOperation.GetDictInfo(Request.QueryString["rowid"]);
            if (dtSource.Rows.Count > 0)
            {
                txtName.Text = dtSource.Rows[0]["name"].ToString();
                txtKeyvalue.Text = dtSource.Rows[0]["KEYVALUE"].ToString();
                txtKeycode.Text = dtSource.Rows[0]["KEYCODE"].ToString();
            }
        }
        if (action != "addroot")
        {
            txtName.Enabled = false;
        }
        if (action == "add")
        {
            txtName.Text = Request.QueryString["name"];
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(txtName.Text) && !string.IsNullOrEmpty(txtKeyvalue.Text))
        {
            dicOperation.AddDictItem(txtName.Text, txtKeyvalue.Text, txtKeycode.Text);

            Response.Redirect("DictionaryItemManager.aspx?name=" + txtName.Text);
        }
    }
    protected void btnReturn_Click(object sender, EventArgs e)
    {
        Response.Redirect("DictionaryItemManager.aspx?name=" + txtName.Text);
    }
}
